/*----------------------------------------------------------------------------
Owner(s): Shane Whitfield
$Copyright: $
$Id: $
----------------------------------------------------------------------------*/

#include "player.h"
#include "bbmath.h"

/*--------------------------------------------------------------------------*/

CPlayer::CPlayer()
{
	m_minerals = 0.0f;
	
#if DEBUG
	m_isInGodMode = false;
#endif
}

void CPlayer::AddMinerals(float i_mineralsToAdd)
{
	m_minerals += i_mineralsToAdd;
}

void CPlayer::UseMinerals(float i_mineralsTouse)
{
	//subtract any incoming minerals, but ensure the minerals never go below 0
	// $$$$ BB (SAW) Later lets look at where this is called. Perhaps we should
	//		put an assert in here making sure we never go below zero. If we do
	//		it could be a system not checking mineral counting before allowing game play to happen.
	m_minerals = BBMIN(0, m_minerals - i_mineralsTouse);
}

void CPlayer::SetMineralCount(float i_mineralCount)
{
	m_minerals = i_mineralCount;
}

#if DEBUG
void CPlayer::On_Command(const char* i_command, const char* i_parameters)
{
	if (!strcmp(i_command, "god"))
	{
		m_isInGodMode = atoi(i_parameters) != 0;
	}
	else if (!strcmp(i_command, "give_minerals"))
	{
		AddMinerals(atof(i_parameters));
	}
}
#endif 

/*-----------------------------------EOF!-----------------------------------*/ 